<template>
  <el-row class="container h-full">
    <el-col :span="12" class="h-full">
      <el-menu :default-active="activeIndex" class="h-full" :router="true">
        <el-menu-item index="/profile/userInfo">
          <template #title>
            <el-icon><icon-menu /></el-icon>
            <span>我的信息</span>
          </template>
        </el-menu-item>
        <el-menu-item index="/profile/myReserve">
          <el-icon><location /></el-icon>
          <span>预定房间</span>
        </el-menu-item>
        <el-menu-item index="/profile/settings">
          <el-icon><setting /></el-icon>
          <span>设置</span>
        </el-menu-item>
      </el-menu>
    </el-col>
    <el-col :span="12">
      <div class="w-full h-full"><router-view /></div>
    </el-col>
  </el-row>
</template>

<script setup>
import { Menu as IconMenu, Setting } from "@element-plus/icons-vue";
import { ref, watch } from "vue";
import { useRoute } from "vue-router";

const activeIndex = ref("/profile/userInfo");
const route = useRoute();

function setCurrentRoute() {
  activeIndex.value = route.path;
}
watch(
  () => activeIndex,
  (value, oldValue) => {
    setCurrentRoute();
    console.log(value, oldValue);
  },
  { immediate: true }
);
</script>
<style lang="scss" scoped>
.container {
  width: 33%;
}
</style>
